package MianShi.designpatterns;

/**
 * @author wys
 * created in 15:09 2019/3/4
 * 代理设计模式
 *
 */

interface NetWork {
    public void browse();
}

// 真实的上网操作
class Real implements NetWork {

    @Override
    public void browse() {
        System.out.println(" 上网流量信息 ");
    }
}

class Proxy implements NetWork {
    private NetWork netWork;

    public Proxy(NetWork netWork) {
        this.netWork = netWork;
    }

    public void check() {
        System.out.println(" 检查用户是否合法! ");
    }

    @Override
    public void browse() {
        this.check();
        this.netWork.browse();
    }
}

public class ProxyDesign {

    public static void main(String args[]) {
        NetWork net = null;
        net = new Proxy(new Real());
        net.browse();
    }


}


